# 创建一个元组
my_tuple = (1, 2, 3, 4, 5)

# 索引操作
print(my_tuple[0])  # 输出第一个元素
print(my_tuple[-1])  # 输出最后一个元素

# 切片操作
print(my_tuple[1:3])  # 输出第二个和第三个元素
print(my_tuple[:2])  # 输出前两个元素
print(my_tuple[3:])  # 输出后两个元素

# 拼接操作
another_tuple = (6, 7, 8)
combined_tuple = my_tuple + another_tuple
print(combined_tuple)

# 循环遍历
for item in my_tuple:
    print(item)

# 长度计算
print(len(my_tuple))

# 成员关系测试
print(3 in my_tuple)
print(9 not in my_tuple)
